import Vue from 'vue'
import Router from 'vue-router'
// import Layout from '@/layout'

Vue.use(Router)

/**
 * 固定路由 不需要权限验证
 */
export const constantRoutes = [
  // {
  //   path: '/',
  //   component: Layout,
  //   redirect: '/home',
  //   meta: { title: '首页', icon: 'nav_home' },
  //   children: [{
  //     path: 'home',
  //     name: 'Home',
  //     component: () => import('@/views/home/index'),
  //     meta: { title: '首页', icon: 'nav_home', serveName: 'home' }
  //   }]
  // },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
